<script setup lang="ts">
import { ref ,computed} from 'vue'
const firstName=ref('curry')
const lastName=ref('stephen')

const fullName=computed(
//   ()=>{
//   return firstName.value + '. ' + lastName.value
// }
{
  //完整写法   使用的不多
  get(){
    return firstName.value + '| ' + lastName.value 
  },
  set(value){
  const  arr=value.split('-') 
  firstName.value=arr[0]
  lastName.value=arr[1]

  }
}
)

</script>

<template>
<h2>{{ fullName }}</h2>
<button @click="firstName+='1'">修改firstName</button>
<button @click="lastName+='1'">修改lastName</button>
<!-- 点击修改fullName -->
<button @click="fullName='hey-bro'">修改fullName</button>
</template>

<style>

</style>
